package com.gms.action;

import java.util.List;
import java.util.Map;

import org.apache.struts2.interceptor.RequestAware;

import com.gms.domain.Product;
import com.gms.service.ProductService;
import com.opensymphony.xwork2.ActionSupport;

public class FindProductByProductNameAction extends ActionSupport implements RequestAware {
	
	private ProductService productService;
	private String productName;
	private Map<String,Object> request;
	
	public String getProductName() {
		return productName;
	}
	public void setProductName(String productName) {
		this.productName = productName;
	}

	
	public ProductService getProductService() {
		return productService;
	}
	public void setProductService(ProductService productService) {
		this.productService = productService;
	}
	@Override
	public String execute() throws Exception {
		// TODO Auto-generated method stub
		System.out.println("in findProductByProductName");
		productName = new String(productName.getBytes("iso-8859-1"),"utf-8");
		System.out.println(productName);
		
		List<Product> productList = productService.findProductByProductName(productName);
		 
		for(Product pro:productList){
			System.out.println(pro.getProductName());
		}
		request.put("productList", productList);
		return "success";
	}
	@Override
	public void setRequest(Map<String, Object> request) {
		// TODO Auto-generated method stub
		this.request = request;
	}
	

}
